package cn.itcast.mq.config;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectConfig {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("direct.queue1"),
            exchange = @Exchange(name = "itcast.direct"),
            key = {"党卫军", "A集团军"}
    ))
    public void listenDirectQueue1(String msg) {
        System.out.println("A集团军接收的消息为: " + msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("direct.queue2"),
            exchange = @Exchange(name = "itcast.direct"),
            key = {"党卫军", "B集团军"}
    ))
    public void listenDirectQueue2(String msg) {
        System.out.println("B集团军接收的消息为: " + msg);
    }
}
